const express = require('express')
const app = express()
const path = require('path')
let bodyParser = require('body-parser');
const tranlsateRouter = require('./route/translate')

app.use(express.static(path.resolve(__dirname, '../public')));
// app.use(express.json());
app.use(bodyParser.urlencoded({extended: false}))

app.get('/', (req, res) => {
    res.setHeader('content-type', 'text/html;charset=utf-8')
    res.redirect('/index');
});

app.post('/translate', tranlsateRouter)


let listen = app.listen(54430, err => {
    if(!err){
        console.log("翻译启动成功: " + listen.address().port)
    }else{
        console.log(err, "翻译启动失败")
    }
})

